import React, { Component } from 'react';

// 引入饼形图组件
import Pie from '@/components/Pie'
// 引入数据请求
import req from '@/http/request'
// 引入接口地址
import url from '@/config/url'
class Welcome extends Component {
    state = {
        accessFrom: [],
        area: [],
        gender: []
    }
    render() {
        const { accessFrom, area, gender } = this.state
        return (
            <div style={{ display: 'flex', }}>
                <Pie text='千锋男女比例' legend={true} data={gender} id='pie1' name='gender'></Pie>
                <Pie text='千锋学生分布' legend={true} data={area} id='pie2' name='area'></Pie>
                <Pie text='千锋学生来源' legend={false} data={accessFrom} id='pie3' name='accessFrom'></Pie>
                <Pie text='千锋男女比例' legend={false} data={gender} id='pie4' name='gender'></Pie>
            </div>
        );
    };
    componentDidMount() {
        // 请求数据
        req.get(url.getData).then(res => {
            console.log(res);
            this.setState({
                accessFrom: res.data.data.accessFrom,
                area: res.data.data.area,
                gender: res.data.data.gender
            })
        })
    }

}


export default Welcome;
